IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spTletters_Create')
	BEGIN
		PRINT 'Dropping Procedure spTletters_Create'
		DROP  Procedure  spTletters_Create
	END

GO

PRINT 'Creating Procedure spTletters_Create'
GO
CREATE Procedure dbo.spTletters_Create
	( 	  
	  @ilpnumber varchar(50) = null, 
		@letterreference varchar(50) = null, 
		@letternotes varchar(500) = null, 
		@letteruser varchar(50) = null, 
		@senttoprimaryemail varchar(50) = null, 
		@senttosecondaryemail varchar(50) = null
	)
AS
  /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 8/23/2007    Initial version created
    ------------------------------------------------------------------------------
  */

	-- Declare the required variables

	-- Create the required new record
	INSERT INTO Tletters
	  (
		ilpnumber,
			letterreference,
			letternotes,
			letteruser,
			senttoprimaryemail,
			senttosecondaryemail	  
	  )
	VALUES
	  (
		@ilpnumber,
			@letterreference,
			@letternotes,
			@letteruser,
			@senttoprimaryemail,
			@senttosecondaryemail
	  )

	-- Handle any errors
	IF @@ERROR != 0
	BEGIN
		RAISERROR('spTletters_Create: Unable to Insert a new Tletters', 10, 1)
		RETURN
	END

	-- Return the newly created ID
	SELECT	@@IDENTITY AS 'Tletters_ID'

	-- Return to calling method
	RETURN 

GO
